<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>新增菜单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <div th:replace="comm/page::layui_css"/>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" action="">
            <input name="id" type="hidden" th:if="${user!=null}" th:value="${user?.id}">
            <!--            <input name="status" type="hidden" th:value="1">-->
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input type="text" name="username" th:value="${user?.username}"
                           lay-verify="required" class="layui-input"
                           lay-reqtext="请输入用户名？"
                           placeholder="请输入用户名"
                    >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                    <input type="text" name="email" lay-verify="required|email"
                           lay-reqtext="请输入合法邮箱？" autocomplete="off"
                           placeholder="请输入邮箱" class="layui-input"
                           th:value="${user?.email}">
                </div>
            </div>
<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">密码</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input type="password" name="password" lay-verify="required"-->
<!--                           placeholder="请输入邮箱"   autocomplete="off" class="layui-input"-->
<!--                           th:value="${user?.password}">-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">确认密码</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input type="password" name="password2" lay-verify="required"-->
<!--                           placeholder="请输入邮箱"   autocomplete="off" class="layui-input"-->
<!--                           th:value="">-->
<!--                </div>-->
<!--            </div>-->
            <div class="layui-form-item">
                <label class="layui-form-label">手机</label>
                <div class="layui-input-block">
                    <input type="text" name="mobile"
                          autocomplete="off" class="layui-input"
                           lay-verify="required|phone"
                           lay-reqtext="请输入合法手机号？" placeholder="请输入手机"
                           th:value="${user?.mobile}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <input type="text" name="remark"
                           placeholder="" autocomplete="off" class="layui-input"
                           th:value="${user?.remark}">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-filter="edit" lay-submit>确定</button>
                </div>
            </div>
        </form>
    </div>
</div>

<div th:replace="comm/page::layui_script"/>
<script>
    var index = parent.layer.getFrameIndex(window.name);
    layui.use([ 'form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        form.on('submit(edit)', function (ret) {
            var data = ret.field;
            $.post("/user/edit", data, function (e) {
                if (e.code === 0) {
                    layer.msg(e.msg);
                    // parent.layer.msg('您将标记 [ ' +val + ' ] 成功传送给了父窗口');
                    index && parent && parent.layer && parent.layer.close(index);
                    parent && parent.refreshView && parent.refreshView();

                } else {
                    layer.msg(e.msg);
                }
            });
            return false;
        });
    });
</script>

</body>
</html>